package at.fhhgb.mc.Aufgabe01;

/**
 * The class ListQueue extends the class DoubleLinkedList.
 * It provides all methods to create a queue, based on a double-linked-list, and to work with it
 * @author Konrad
 *
 */
public class ListQueue extends DoubleLinkedList {

	/**
	 * Constructor for the class. Sets head and tail to null
	 */
	public ListQueue() {
		super();
	}

	/**
	 * Initializes the queue with another queue
	 * @param other Other queue that will be copied
	 */
	public ListQueue(ListQueue other) {
		@SuppressWarnings("unused")
		DoubleLinkedList tempQueue = other.clone();
		boolean endOfList = false;
		do {
			if (other.peekFront() == Integer.MIN_VALUE) {
				endOfList = true;
			} else {
				this.enqueue(other.dequeue());
			}
		} while (endOfList == false);
	}

	/**
	 * Enqueues an element
	 * @param val Value that will be enqueued
	 */
	public void enqueue(int val) {
		super.pushBack(val);
	}

	/**
	 * Dequeues an element
	 * @return Returns the front element of the queue
	 */
	public int dequeue() {
		return super.popFront();
	}

	/**
	 * Peeks the front element of the queue
	 * @return Returns the front element of the queue
	 */
	public int peek() {
		return super.peekFront();
	}

}
